package com.nf.action;

import com.nf.entity.Car1;
import com.nf.entity.IPrivce;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class TestAction {
    private IPrivce iPrivce;

    @RequestMapping("/tttt")
    public String ss(Model model, float a){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        iPrivce = (IPrivce)ac.getBean("privceB");

        float z = iPrivce.show(a);
        model.addAttribute("z",z);

        return "a1";
    }

//读取bean里面注入的构造方法值
    @RequestMapping("/t2")
    public String ss2(Model model){
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        Car1 car1 = (Car1) ac.getBean("getPrivce");

        model.addAttribute("name",car1.getName());
        model.addAttribute("sum",car1.getSum());
        model.addAttribute("privce",car1.getPrivce());
        return "aa";
    }
}
